package controladores;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import dominio.Cliente;
import dominio.PaqueteDeViaje;

public class PaqueteServlet extends GenericServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	public PaqueteServlet(){
		super();
	}

	public void doAction(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		
		try {			
			List<PaqueteDeViaje> pdv = new PaqueteDeViaje().leerRegistrosBD();
			String[] idsCliente = request.getParameterValues("cliente");
			String idReserva = request.getParameter("reserva");
			String datosReserva = "";
			
			if(idReserva != null){
				datosReserva = "&reserva=" + idReserva;
			}
			
			if(idsCliente != null) {
				for (String idc : idsCliente) {
					datosReserva += "&cliente=" + idc;
				}
			}
			
			request.setAttribute("datosReserva", datosReserva);
			request.setAttribute("pdv", pdv);	
			request.getRequestDispatcher("/paquetes.jsp").forward(request, response);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
